package methodImportUse.test2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.stream.Collectors;

public class StuTest2 {
    public static void main(String[] args) {
        //将学生集合收集到学生类型的数组中
        //1.创建集合并添加数据
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list, "jack,22", "tom,33", "kk,23");
      /*  List<String> list1 = list.stream().map(new Function<String, String>() {
            @Override
            public String apply(String s) {
                return s.split(",")[0];
            }
        }).collect(Collectors.toList());
        System.out.println(list1);*/
        //进行方法引用
       /* String[] arr = list.stream().map(Student::Name).toArray(new IntFunction<String[]>() {
            @Override
            public String[] apply(int value) {
                return new String[value];
            }
        });
        System.out.println(Arrays.toString(arr));
*/
        String[] arr = list.stream().map(Student::name).toArray(String[]::new);
        System.out.println(Arrays.toString(arr));

    }
}
